package cn.edu.scau.cmi.yangqing.factory;

import java.net.URL;
import java.util.ResourceBundle;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.TextField;

public class FactoryController implements Initializable {

	@FXML
	   private Button myButton;

	   @FXML
	   private ChoiceBox<String> myChoiceBox;

	   @FXML
	   private TextField myTextField2;
	   public void initialize(URL location, ResourceBundle resources) {

	   }

	   public void showDateTime2(ActionEvent event) {
	       System.out.println("Button Clicked!");
	       System.out.println(myChoiceBox.getSelectionModel().getSelectedIndex());
	       
	       Integer checkboxIndex = myChoiceBox.getSelectionModel().getSelectedIndex();
	       CreateFactory factory = null;
	       switch (checkboxIndex) {
			case 0:
			    factory = new DriverInsuranceFactory();
				break;
			case 1:
				factory = new CarInsuranceFactory();
				break;
			case 2:
				factory = new PersonInsuranceFactory();
				break;
			case 3:
				factory = new MutilInsuranceFactory();
				break;
			default:
				break;
		}
	       Insurance insurance =  factory.factory();
	       String output = insurance.getInsurance();
	       myTextField2.setText(output);
	   }
}
